package com.mxgraph.swing;

import com.mxgraph.model.mxCell;
import com.neuronbit.businessflow.intellij.editor.swing.XmlWriter;
import com.neuronbit.businessflow.intellij.editor.swing.editor.BasicGraphEditor;
import com.neuronbit.businessflow.intellij.editor.swing.editor.ModuleProvider;
import com.neuronbit.businessflow.intellij.editor.swing.editor.RadComponent;
import com.neuronbit.businessflow.intellij.model.Decision;

/**
 * The type Rad edge component.
 */
public class RadEdgeComponent extends RadComponent {
    private final ModuleProvider moduleProvider;

    /**
     * Instantiates a new Rad edge component.
     *
     * @param moduleProvider the module provider
     * @param cell           the cell
     * @param id             the id
     */
    public RadEdgeComponent(ModuleProvider moduleProvider, mxCell cell, String id) {
        super(moduleProvider, cell, id);
        this.moduleProvider = moduleProvider;
    }

    /**
     * Is decision boolean.
     *
     * @return the boolean
     */
    public boolean isDecision() {
        return this.getDelegee().getSource()!=null && this.getDelegee().getSource().getValue()!= null
                && this.getDelegee().getSource().getValue() instanceof Decision;
    }

    @Override
    public void write(XmlWriter writer) {

    }

    /**
     * Sets value.
     *
     * @param value the value
     */
    public void setValue(String value) {
        ((mxGraphComponent) moduleProvider).labelChanged(getDelegee(), value, null);
    }
}
